/*
 * The MiniQt Library
 *
 * Copyright (C) 1999 Sandro Sigala <ssigala@globalnet.it>
 */

#include <windows.h>

#include "qapplication.h"
#include "qpushbutton.h"

QPushButton::QPushButton(const QString& caption, QWidget *parent, const char *name)
	: QWidget(parent, name, WType_Child)
{
#ifdef DEBUG
	qDebug("obj", "QPushButton::constructor of \"%s\"", name ? name : "unnamed");
#endif

	HWND hwnd = CreateWindow(
	    "BUTTON",	            		// class name
	    caption,        	    		// window name
	    WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,  // style
            CW_USEDEFAULT,	    		// geometry
            CW_USEDEFAULT,
            CW_USEDEFAULT,
            CW_USEDEFAULT,
	    parent->winId(),
	    (HMENU)NULL,            		// class menu used
	    hInstance, 	    	    		// instance handle
	    NULL);                  		// no window creation data

	setCaption(caption);

	if (hwnd == (HWND)0)
		qFatal("cannot create button");

	setWinId(hwnd);
	registerWinId(hwnd, this);
}

QPushButton::~QPushButton()
{
#ifdef DEBUG
	qDebug("obj", "QPushButton::destructor of \"%s\"", name("unnamed"));
#endif
}

void QPushButton::mouseReleaseEvent(QMouseEvent * /*e*/)
{
	emit clicked();
}
